package com.sunny.shop.api.v1;

import com.sunny.shop.core.interceptors.ScopeLevel;
import com.sunny.shop.exception.httpe.Success;
import com.sunny.shop.model.Collect;
import com.sunny.shop.model.Riddle;
import com.sunny.shop.service.RiddleServiceImpl;
import com.sunny.shop.vo.RiddleVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/riddle")
public class RiddleController {
    @Autowired
    private RiddleServiceImpl riddleService;

    @ScopeLevel()
    @GetMapping("/{cateId}")
    public List<RiddleVO> getRiddles(@PathVariable Long cateId){
        List<RiddleVO> riddles = this.riddleService.getRiddles(cateId);
        return riddles;
    }


    @ScopeLevel()
    @PostMapping("/collect/{id}")
    public void addCollect(@PathVariable Long id){
        this.riddleService.addCollect(id);
        throw new Success(90001);
    }
}
